export type ArtifactMetadata = Record; export type PatchApiRepoChannelNameCkeyArgs = {channel_name: string, ckey: unknown, body: ArtifactMetadata}; export type PatchApiRepoChannelNameCkeyOptions = {baseUrl?: string | undefined, jwt?: string | undefined, fetch?: typeof fetch | undefined}; /** * Patch artifact metadata * * PATCH /repo/{channel_name}/{ckey:[^/].*?} * * Also accepts auth: user_token */ export const patchApiRepoChannelNameCkey = async (args: PatchApiRepoChannelNameCkeyArgs, options?: PatchApiRepoChannelNameCkeyOptions) => { const {baseUrl = "https://api.anaconda.cloud/api", fetch: fetchFn = fetch, jwt} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (jwt !== undefined) headers.set('authorization', `Bearer ${jwt}`) const url = `${baseUrl.replace(/\/+$/, '')}/repo/${encodeURIComponent(String(args.channel_name))}/${encodeURIComponent(String(args['ckey:[^/].*?']))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };